package com.situ.library.service.impl;

import com.situ.library.dao.IRecordDao;
import com.situ.library.dao.impl.RecordDaoImpl;
import com.situ.library.pojo.entity.Record;
import com.situ.library.pojo.query.RecordQuery;
import com.situ.library.pojo.vo.RecordVO;
import com.situ.library.service.IRecordService;
import com.situ.library.util.PageInfo;

import java.util.List;

public class RecordServiceImpl implements IRecordService {
    private IRecordDao recordDao = new RecordDaoImpl();

    @Override
    public PageInfo selectByPage(RecordQuery recordQuery) {
        List<RecordVO> list = recordDao.selectByPage(recordQuery);
        //现在要搜索的是符合条件的总的数量
        int totalCount = recordDao.selectTotalCount(recordQuery);

        return PageInfo.ok(totalCount, list);
    }

    @Override
    public void add(Record record) {
        recordDao.add(record);
    }

    @Override
    public Record selectById(int id) {
        return recordDao.selectById(id);
    }

    @Override
    public void update(Record record) {
        recordDao.update(record);
    }

    @Override
    public void updateStatus(int id, int status) {
        recordDao.updateStatus(id, status);
    }
}
